/*
 * @author Chris
 * @since 2023/1/23 21:43
 *
 * @brief    The project will ...
 *
 * @note     ...
 *
 * @warning  Do not to ...
 *
 * Change Logs:
 *   Date           Author       Notes
 *   2023/1/23     Chris        the first version
 */

#include "reg51.h"

void ConfigUART(unsigned int baud);

int main() {

    ConfigUART(9600);

    while (1) {
        while (!RI);
        RI = 0;
        SBUF += 1;
        while (!TI);
        TI = 0;
    }
}

void ConfigUART(unsigned int baud) {
    SCON |= 0x50;   // 串口模式 1
    TMOD |= 0x20;   // 定时器 T1 工作模式 2，自动重装模式
    TH1 = 256 - (11059200 / 12 / 2 / 16) / baud;
    TL1 = TH1;

    ET1 = 1;    // 禁止定时器 T1 中断
    TR1 = 1;    // 启动定时器 T1
}
